//
//  WBNavigationController.swift
//  weibo
//
//  Created by GOD on 16/9/2.
//  Copyright © 2016年 磊王. All rights reserved.
//

import UIKit

class WBNavigationController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //navigationBarHidden = true
        navigationBar.hidden = true
    }
    @objc private func back(){
        popViewControllerAnimated(true)
    
    
    }
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        //如果不是栈底控制器才需要隐藏
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? WBBaseViewController {
                var title = "返回"
                if childViewControllers.count == 1 {
                    title = childViewControllers.first?.title ?? "返回"
                }
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, fontSize: 16, target: self, action: #selector(back),isBackButton: true)
                
                
            }
        }
        
        super.pushViewController(viewController, animated: true)
        
    }
    
   }
